package com.test.learnopenglandroid;

import android.util.Log;

import org.apache.commons.math3.linear.ArrayRealVector;
import org.apache.commons.math3.linear.RealVector;

public class VectorMatrixHelper {
    static public void showMatrix4x4(float[] mTransMatrix){
        StringBuilder builder = new StringBuilder();
        if(mTransMatrix.length == 16){
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    builder.append(mTransMatrix[i*4+j]);
                    builder.append(",");
                }
                builder.append("\n");
            }
        }
        Log.i("yhy",builder.toString());
    }

    public static RealVector crossProduct(RealVector value1, RealVector value2){
        double x1 = value1.getEntry(0);
        double y1 = value1.getEntry(1);
        double z1 = value1.getEntry(2);

        double x2 = value2.getEntry(0);
        double y2 = value2.getEntry(1);
        double z2 = value2.getEntry(2);
        return new ArrayRealVector(new double[]{y1*z2-y2*z1, (x1*z2-x2*z1)*-1, x1*y2-x2*y1});
    }
}
